package gt.edu.usac.viewcontroller.backing.app;

import gt.edu.usac.model.am.AppModuleImpl;
import gt.edu.usac.viewcontroller.utils.JSFUtils;

import java.io.IOException;

import javax.faces.component.html.HtmlForm;

import javax.faces.context.FacesContext;

import javax.faces.el.ValueBinding;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCDataControl;
import oracle.adf.view.faces.component.core.data.CoreColumn;
import oracle.adf.view.faces.component.core.data.CoreTable;
import oracle.adf.view.faces.component.core.layout.CorePanelHeader;
import oracle.adf.view.faces.component.core.layout.CorePanelList;
import oracle.adf.view.faces.component.core.layout.CorePanelTip;
import oracle.adf.view.faces.component.core.nav.CoreCommandLink;
import oracle.adf.view.faces.component.core.output.CoreOutputText;

import oracle.binding.BindingContainer;
import oracle.binding.AttributeBinding;
import oracle.binding.OperationBinding;

import oracle.jbo.ApplicationModule;

public class SolicitarGestion {
    private HtmlForm form1;
    private CorePanelHeader panelHeader1;
    private CorePanelTip panelTip1;
    private CoreOutputText outputText1;
    private CorePanelList panelList1;
    private CoreCommandLink commandLink1;
    private CoreCommandLink commandLink2;
    private CoreCommandLink commandLink3;
    private CoreCommandLink commandLink4;
    private CoreCommandLink commandLink5;
    private CorePanelHeader panelHeader2;
    private CoreTable table1;
    private CoreColumn column1;
    private CoreOutputText outputText2;
    private CoreColumn column2;
    private CoreOutputText outputText3;
    private CoreColumn column3;
    private CoreOutputText outputText4;
    private CoreColumn column4;
    private CoreOutputText outputText5;
    private CoreColumn column5;
    private CoreOutputText outputText6;
    private CoreColumn column6;
    private CoreOutputText outputText7;
    private CoreColumn column7;
    private CoreOutputText outputText8;
    private CoreColumn column8;
    private CoreOutputText outputText9;
    
    private BindingContainer bindings;
    private CoreCommandLink commandLink6;

    public void setForm1(HtmlForm form1) {
        this.form1 = form1;
    }

    public HtmlForm getForm1() {
        return form1;
    }

    public void setPanelHeader1(CorePanelHeader panelHeader1) {
        this.panelHeader1 = panelHeader1;
    }

    public CorePanelHeader getPanelHeader1() {
        return panelHeader1;
    }

    public void setPanelTip1(CorePanelTip panelTip1) {
        this.panelTip1 = panelTip1;
    }

    public CorePanelTip getPanelTip1() {
        return panelTip1;
    }

    public void setOutputText1(CoreOutputText outputText1) {
        this.outputText1 = outputText1;
    }

    public CoreOutputText getOutputText1() {
        return outputText1;
    }


    public void setPanelList1(CorePanelList panelList1) {
        this.panelList1 = panelList1;
    }

    public CorePanelList getPanelList1() {
        return panelList1;
    }

    public void setCommandLink1(CoreCommandLink commandLink1) {
        this.commandLink1 = commandLink1;
    }

    public CoreCommandLink getCommandLink1() {
        return commandLink1;
    }

    public void setCommandLink2(CoreCommandLink commandLink2) {
        this.commandLink2 = commandLink2;
    }

    public CoreCommandLink getCommandLink2() {
        return commandLink2;
    }

    public void setCommandLink3(CoreCommandLink commandLink3) {
        this.commandLink3 = commandLink3;
    }

    public CoreCommandLink getCommandLink3() {
        return commandLink3;
    }

    public void setCommandLink4(CoreCommandLink commandLink4) {
        this.commandLink4 = commandLink4;
    }

    public CoreCommandLink getCommandLink4() {
        return commandLink4;
    }

    public void setCommandLink5(CoreCommandLink commandLink5) {
        this.commandLink5 = commandLink5;
    }

    public CoreCommandLink getCommandLink5() {
        return commandLink5;
    }

    public void setPanelHeader2(CorePanelHeader panelHeader2) {
        this.panelHeader2 = panelHeader2;
    }

    public CorePanelHeader getPanelHeader2() {
        return panelHeader2;
    }

    public void setTable1(CoreTable table1) {
        this.table1 = table1;
    }

    public CoreTable getTable1() {
        return table1;
    }

    public void setColumn1(CoreColumn column1) {
        this.column1 = column1;
    }

    public CoreColumn getColumn1() {
        return column1;
    }

    public void setOutputText2(CoreOutputText outputText2) {
        this.outputText2 = outputText2;
    }

    public CoreOutputText getOutputText2() {
        return outputText2;
    }

    public void setColumn2(CoreColumn column2) {
        this.column2 = column2;
    }

    public CoreColumn getColumn2() {
        return column2;
    }

    public void setOutputText3(CoreOutputText outputText3) {
        this.outputText3 = outputText3;
    }

    public CoreOutputText getOutputText3() {
        return outputText3;
    }

    public void setColumn3(CoreColumn column3) {
        this.column3 = column3;
    }

    public CoreColumn getColumn3() {
        return column3;
    }

    public void setOutputText4(CoreOutputText outputText4) {
        this.outputText4 = outputText4;
    }

    public CoreOutputText getOutputText4() {
        return outputText4;
    }

    public void setColumn4(CoreColumn column4) {
        this.column4 = column4;
    }

    public CoreColumn getColumn4() {
        return column4;
    }

    public void setOutputText5(CoreOutputText outputText5) {
        this.outputText5 = outputText5;
    }

    public CoreOutputText getOutputText5() {
        return outputText5;
    }

    public void setColumn5(CoreColumn column5) {
        this.column5 = column5;
    }

    public CoreColumn getColumn5() {
        return column5;
    }

    public void setOutputText6(CoreOutputText outputText6) {
        this.outputText6 = outputText6;
    }

    public CoreOutputText getOutputText6() {
        return outputText6;
    }

    public void setColumn6(CoreColumn column6) {
        this.column6 = column6;
    }

    public CoreColumn getColumn6() {
        return column6;
    }

    public void setOutputText7(CoreOutputText outputText7) {
        this.outputText7 = outputText7;
    }

    public CoreOutputText getOutputText7() {
        return outputText7;
    }

    public void setColumn7(CoreColumn column7) {
        this.column7 = column7;
    }

    public CoreColumn getColumn7() {
        return column7;
    }

    public void setOutputText8(CoreOutputText outputText8) {
        this.outputText8 = outputText8;
    }

    public CoreOutputText getOutputText8() {
        return outputText8;
    }

    public void setColumn8(CoreColumn column8) {
        this.column8 = column8;
    }

    public CoreColumn getColumn8() {
        return column8;
    }

    public void setOutputText9(CoreOutputText outputText9) {
        this.outputText9 = outputText9;
    }

    public CoreOutputText getOutputText9() {
        return outputText9;
    }

    public String consultarNotas_action() {
        /*BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("ExecuteWithParams");
        Object result = operationBinding.execute();
        
        if (!operationBinding.getErrors().isEmpty()) {
            return null;
        }
        
        JSFUtils.setExpressionValue("#{bindings.showNotas.inputValue}","1");*/
         BindingContainer bindings = getBindings();
         // get an ADF attribute value from the ADF page definitions
         //AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("usuario");attr.getInputValue()
         String username = JSFUtils.resolveExpression("#{Globales.userName}").toString();
         try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("/calusacestudiante/listadocursos?pusuario="+username);
         } catch (Exception e) {
             System.out.println(e);
         }
        return null;
    }

    private AppModuleImpl getService(){
        FacesContext ctx = FacesContext.getCurrentInstance();
        
        //Creando el binding container 
        ValueBinding vb = ctx.getApplication().createValueBinding("#{data}");
        BindingContext bc = (BindingContext)vb.getValue(ctx);
        
        DCDataControl dc  = bc.findDataControl("AppModuleDataControl");
        ApplicationModule am = (ApplicationModule)dc.getDataProvider();
        return (AppModuleImpl)am;
    }

    public void setBindings(BindingContainer bindings) {
        this.bindings = bindings;
    }

    public BindingContainer getBindings() {
        return bindings;
    }

    public void setCommandLink6(CoreCommandLink commandLink6) {
        this.commandLink6 = commandLink6;
    }

    public CoreCommandLink getCommandLink6() {
        return commandLink6;
    }

    public String regresar_action() {
        JSFUtils.setExpressionValue("#{bindings.showNotas.inputValue}","0");
        return null;
    }
}
